<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function() {

    var gradient = document.createElement('canvas').getContext('2d').createLinearGradient(0, 0, 150, 0);

    assert_throws_dom("INDEX_SIZE_ERR", function() {
      gradient.addColorStop(-1, '#000');
    });
    assert_throws_dom("INDEX_SIZE_ERR", function() {
      gradient.addColorStop(2, '#000');
    });
    assert_throws_js(TypeError, function() {
      gradient.addColorStop(Infinity, '#000');
    });
    assert_throws_js(TypeError, function() {
      gradient.addColorStop(-Infinity, '#000');
    });
    assert_throws_js(TypeError, function() {
      gradient.addColorStop(NaN, '#000');
    });
}, 'This test checks invalid offsets on gradients.');
</script>
